/*
 * Copyright 2016 KairosDB Authors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package org.kairosdb.core.datastore;

import org.kairosdb.core.DataPoint;
import org.kairosdb.core.groupby.GroupByResult;

import java.util.Collections;
import java.util.List;
import java.util.Set;

public class DataPointGroupRowWrapper implements DataPointGroup
{
	private final DataPointRow m_row;

	public DataPointGroupRowWrapper(DataPointRow row)
	{
		m_row = row;
	}


	@Override
	public String getName()
	{
		return (m_row.getName());
	}

	@Override
	public String getAlias()
	{
		return null; //Alias is not used from this and is set in the sorted data point group
	}

	@Override
	public Set<String> getTagNames()
	{
		return (m_row.getTagNames());
	}

	@Override
	public Set<String> getTagValues(String tag)
	{
		return (Collections.singleton(m_row.getTagValue(tag)));
	}

	@Override
	public List<GroupByResult> getGroupByResult()
	{
		return null;
	}

	@Override
	public void close()
	{
		m_row.close();
	}

	@Override
	public boolean hasNext()
	{
		return (m_row.hasNext());
	}

	@Override
	public DataPoint next()
	{
		DataPoint dp = m_row.next();
		dp.setDataPointGroup(this);
		return (dp);
	}

	@Override
	public void remove()
	{
		m_row.remove();
	}
}
